home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Gamma Fade 1.1.2 / Gamma Utils Lib v1.1.2 / gamma.h < prev   
Text File  |  1993-11-09  |  5KB  |  108 lines

  1. // File "gamma.h" - Header for Altering the Gamma Tables of GDevices
  2.  
  3. // * ****************************************************************************** *
  4. //
  5. //    This library is intended as a general tool for manipulating the Gamma Tables
  6. //        of Graphics Devices, to ramp them up or down in order to achieve smooth
  7. //        screen fades. The source is included for programmers who want to convert
  8. //        the library to A4-based, but it is not commented for public consumption.
  9. //    The library defines 2 globals to save state data, but the entire Table 
  10. //        manipulation is performed with unlocked handles to be easy on your heap.
  11. //        The typical memory chunk is about 600 bytes for a 13" Monitor in 8-bit 
  12. //        depth, or about 1700 bytes for one in 24-bit color. Usage will vary.
  13. //    Of course, the Classic Mac cannot use Gamma Fades, only Mac II or later machines
  14. //        with attached monitors. (I don't know about the Color Classic tho’!). Also,
  15. //        GDevice manipulation needs to follow InitGraf() & InitWindows() calls.
  16. //    Please use the listed functions to see if you can use this code before you set
  17. //        it up. As usual, this stuff is not warranteed, guaranteed, or anything--
  18. //        use it at your own risk. It is not Apple-recommended for anything, but it
  19. //        worked for me, so there!
  20. //    
  21. //        Written:    12/17/92, Matt Slot, fprefect@engin.umich.edu                
  22. //        
  23. //        Updated:     3/13/93, MJS    (v1.1)                                            
  24. //                        •>    Updated the GammaAvail calls to be more honest.
  25. //                            Actually check to see if Grafix Devices are supported
  26. //                            on this machine w/o using Gestalt. Also, used the 
  27. //                            std. Toolbox calls to test the GDevice attributes.
  28. //                        •>    Removed extraneous calls to lock handles in several
  29. //                            locations.
  30. //                        •>    Fixed bug in DoOneGammaFade which failed if the device
  31. //                            could not be found in the list.
  32. //                        •>    Changed function prototypes to be more intuitive.
  33. //                        •>    Updated the descriptions in header file.
  34. //                        •>  Thanks to David Phillip Oster, oster@well.sf.ca.us,
  35. //                            for his numerous suggestions and criticisms. :)
  36. //        
  37. //        Updated:     11/9/93, MJS    (v1.1.1)                                    
  38. //                        •>    Fixed incompatibility with EvenBetterBusError...
  39. //                            OK, it was an obscure bug (dereferencing once too
  40. //                            often), but didnt seem to break except with EBBE.
  41. //        
  42. //        Updated:     11/9/93, MJS    (v1.1.2)                                    
  43. //                        •>    Left a Debugger() in the posted application.
  44. //    
  45. //        Oh yeah, this stuff is free to anyone interested in it.
  46. //
  47. // * ****************************************************************************** *
  48.  
  49. //    A quick signature
  50. #define kGammaUtilsSig    'GAMA'
  51.  
  52. //    To help check for compatibility
  53. #define kGetDeviceListTrapNum        0xAA29
  54.  
  55. // * ****************************************************************************** *
  56.  
  57. //    Internal data storage
  58. typedef struct globalGammas {
  59.     short size, dataOffset;
  60.     GammaTblHandle saved, hacked;
  61.     GDHandle theGDevice;
  62.     struct globalGammas **next;
  63.     } globalGammas, *globalGammasPtr, **globalGammasHdl;
  64.     
  65. // * ****************************************************************************** *
  66. // * ****************************************************************************** *
  67. // Function Prototypes
  68.  
  69. Boolean IsGammaAvailable(void);
  70. Boolean IsOneGammaAvailable(GDHandle theGDevice);
  71.  
  72. //    These routines help you determine whether you can use the Gamma Table Utils
  73. //        on the current machine. The first checks all attached monitors, and the 
  74. //        second just checks the indicated monitor. Each returns TRUE if you can 
  75. //        use the functions, or FALSE if you can't. • Note: Before calling any other
  76. //        Gamma Table function below, use this function to see if you are allowed.
  77.  
  78. // * ****************************************************************************** *
  79.  
  80. OSErr SetupGammaTools(void);
  81. OSErr DisposeGammaTools(void);
  82.  
  83. //    These routines must bracket any calls to the Gamma Table functions, perhaps
  84. //        at the head and tail of your main(). The first sets up the data structures
  85. //        necessary to save and restore the state of your monitors. The second
  86. //        disposes of all the internal data structures, but does not reset the
  87. //        monitors to their original states. Both return the error code if some
  88. //        part failed. 
  89.  
  90. // * ****************************************************************************** *
  91.  
  92. OSErr DoGammaFade(short percent);
  93. OSErr DoOneGammaFade(GDHandle theGDevice, short percent);
  94.  
  95. //    Use the first function to Fade each of your monitors to some percentage of their
  96. //        initial brightness (100 = bright, 0 = dim). Repeatedly call this to ramp your
  97. //        monitors up or down. The second function performs the same function, but only
  98. //        for the specified monitor. Both return any applicable error codes.
  99. //    Be sure to set up the necessary save-state data structures before you start by
  100. //        calling the compatibility and initialization functions. 
  101.  
  102. // * ****************************************************************************** *
  103.  
  104. OSErr GetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  105. OSErr SetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  106.  
  107. //    These routines are low-level interfaces to the device drivers for the monitors.
  108. //        Use them at your own risk.